// import Mock from 'mockjs';
import Router from 'koa-router';
import proxyService from '../../common/proxyService';
import {
  getH5fissionList, // 获取h5裂变列表
  getH5fissionInfo, // 获取h5裂变详情
  deleteH5fission, // 删除h5裂变
  createH5fission, // 创建h5裂变
  updateH5fission, // 修改h5裂变
  getH5FissionStat, // h5裂变总统计
  getH5FissionStatList, // h5裂变折线
  getH5FissionLevelInfo, // h5裂变层级
  getH5FissionShareInfo, // 获取分享信息
  getH5FissionParticipant, // 获取参与人列表
  getH5FissionHelpList, // 助力列表
} from '../../api';

const router = new Router();

// 获取h5裂变列表
router.get('/getFissionList', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5fissionList);
  return (ctx.body = response);
});

// 获取h5裂变详情
router.get('/getFissinInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5fissionInfo);
  return (ctx.body = response);
});

// 删除h5裂变
router.post('/deleteFission', async ctx => {
  const response = await proxyService.postProxy(ctx, deleteH5fission);
  return (ctx.body = response);
});

// 新建h5裂变
router.post('/saveFission', async ctx => {
  const response = await proxyService.postProxy(ctx, createH5fission);
  return (ctx.body = response);
});

// 修改h5裂变
router.post('/updateFission', async ctx => {
  const response = await proxyService.postProxy(ctx, updateH5fission);
  return (ctx.body = response);
});

// h5裂变总统计
router.post('/getH5FissionStat', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionStat);
  return (ctx.body = response);
});

// h5裂变折线
router.post('/getH5FissionStatList', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionStatList);
  return (ctx.body = response);
});

// h5裂变层级
router.post('/getH5FissionLevelInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionLevelInfo);
  return (ctx.body = response);
});
// 获取分享信息
router.get('/getH5FissionShareInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionShareInfo);
  return (ctx.body = response);
});

// 获取参与人列表
router.post('/getH5FissionParticipant', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionParticipant);
  // console.log(ctx)
  // const response = await proxyService.mockData({
  //   code: 1,
  //   message: 'ok',
  //   data: {
  //     'records|10': [
  //       {
  //         nickname: '唯有暗香来',
  //         headImageUrl: 'https://xiaodashi.com/logo.png',
  //         'tapNum|+2': 100,
  //         'firstNum|+1': 1,
  //         openId: 'oEQVk0iKb8c_8uNdcmbaTp5csCNQ',
  //       },
  //     ],
  //     total: 20,
  //   },
  // });
  return (ctx.body = response);
});

// 获取h5裂变助力列表
router.post('/getH5FissionHelpList', async ctx => {
  const response = await proxyService.postProxy(ctx, getH5FissionHelpList);
  // const response = await proxyService.mockData({
  //   code: 1,
  //   message: 'ok',
  //   data: {
  //     'records|20': [
  //       {
  //         nickname: '唯有暗香来',
  //         headImageUrl: 'https://xiaodashi.com/logo.png',
  //       },
  //     ],
  //     total: 20,
  //   },
  // });
  return (ctx.body = response);
});

export default router;
